//TIP 要<b>运行</b>代码，请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
    public static void main(String[] args) {

    }
    //链表分割
        public ListNode partition(ListNode pHead, int x) {
            ListNode result = new ListNode(0);
            ListNode result1 = result;
            while(pHead != null&&pHead.val<x){
                result1.next = pHead;
                pHead = pHead.next;
                result1 = result1.next;
            }
            if(pHead == null){
                return result.next;
            }
            ListNode cur = pHead;
            ListNode curN = pHead.next;
            while(curN!=null){
                if(curN.val<x){
                    result1.next = curN;
                    cur.next = curN.next;
                    curN = curN.next;
                    result1 = result1.next;
                }else{
                    cur = curN;
                    curN = curN.next;
                }
            }
            cur.next = null;
            result1.next = pHead;
            return result.next;
        }
    }
